import { baseUrl2 } from "./baseUrl";

export function get(url, params) {
  return new Promise((resolve, reject) => {
    uni.request({
      data: params,
      url: baseUrl2 + url,
      method: "GET",
      timeout: 10000,
      success: (res) => {
        resolve(res);
      },
      fail: (err) => {
        uni.showToast({
          title: "请检查网络连接",
          duration: 2000,
          icon: "none",
          success: function (res) {
            reject(err);
          },
        });
      },
    });
  });
}
export function post(url, params) {
  return new Promise((resolve, reject) => {
    uni.request({
      data: params,
      url: baseUrl2 + url,
      method: "POST",
      timeout: 10000,
      success: (res) => {
        resolve(res);
      },
      fail: (err) => {
        uni.showToast({
          title: "请检查网络连接",
          duration: 2000,
          icon: "none",
          success: function (res) {
            reject(err);
          },
        });
      },
    });
  });
}
